﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Text;

//角色表内数据结构
public class RoleDatabase : TableDatabase
{
    //public int ID;
    public string Name;
    public string ModelPath;
}

//角色表
public class RoleTable : ConfigTable<RoleDatabase, RoleTable>
{
    // id ， 数据条目
    Dictionary<int, RoleDatabase> _cache = new Dictionary<int, RoleDatabase>();

    public RoleTable()
    {
        load("Config/RoleTable.csv");
        //读表
        //Config/RoleTable.csv

        //var table = Resources.Load<TextAsset>("Config/RoleTable");

        //var tableStream = new MemoryStream(table.bytes);

        //using (var reader = new StreamReader(tableStream, Encoding.GetEncoding("gb2312")))
        //{
        //    //跳过第一行
        //    reader.ReadLine();
        //    //正式数据
        //    var lineStr = reader.ReadLine();
        //    while (lineStr != null)
        //    {
        //        var itemStrArray = lineStr.Split(',');
        //        var roleDB = new RoleDatabase();
        //        roleDB.ID = int.Parse(itemStrArray[0]);

        //        roleDB.Name = itemStrArray[1];
        //        roleDB.ModelPath = itemStrArray[2];
        //        _cache[roleDB.ID] = roleDB;

        //        lineStr = reader.ReadLine();
        //    }


        //    reader.Close();
        //    tableStream.Close();

        //}
    }

    //获取表格数据 ---- 索引器
    //public RoleDatabase this[int index]
    //{
    //    get {
    //        RoleDatabase db;
    //        _cache.TryGetValue(index, out db);
    //        return db;
    //    }
    //}

    //public Dictionary<int, RoleDatabase> GetAll()
    //{
    //    return _cache;
    //}

}
